﻿using System;
using System.Globalization;

namespace Gmantis.Controls.Chart
{
    public class BasePieRenderer : BaseRenderer
    {
        // Fields
        private double _innerRadius;
        private double _offset;
        private double _radius = 0.8;

        // Methods
        internal BasePieRenderer()
        {
            base.ColorScheme = ColorScheme.Point;
        }

        internal override string GetValue(string name)
        {
            switch (name)
            {
                case "InnerRadius":
                    return this.InnerRadius.ToString(CultureInfo.InvariantCulture);

                case "Offset":
                    return this.Offset.ToString(CultureInfo.InvariantCulture);
            }
            return "";
        }

        protected override void InitOptions()
        {
            base.OptionsBag.Add("InnerRadius");
            base.OptionsBag.Add("Offset");
        }

        internal override void SetValue(string name, string value)
        {
            string str = name;
            if (str != null)
            {
                if (!(str == "InnerRadius"))
                {
                    if (!(str == "Offset"))
                    {
                        return;
                    }
                }
                else
                {
                    this.InnerRadius = double.Parse(value, CultureInfo.InvariantCulture);
                    return;
                }
                this.Offset = double.Parse(value, CultureInfo.InvariantCulture);
            }
        }

        // Properties
        public double InnerRadius
        {
            get
            {
                return this._innerRadius;
            }
            set
            {
                this._innerRadius = value;
                base.FireChanged(this, EventArgs.Empty);
            }
        }

        public double Offset
        {
            get
            {
                return this._offset;
            }
            set
            {
                this._offset = value;
                base.FireChanged(this, EventArgs.Empty);
            }
        }

        public double Radius
        {
            get
            {
                return this._radius;
            }
            set
            {
                this._radius = value;
                base.FireChanged(this, EventArgs.Empty);
            }
        }
    }
}
